package com.hzy.servlet;

import com.hzy.service.BookingService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Package: com.hzy.servlet
 * @ClassName: CheckCardIdServlet
 * @Author: 862982795
 * @CreateTime: 2021/07/01 21:23
 * @Description:
 */
@WebServlet("/CheckCardIdServlet")
public class CheckCardIdServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        resp.setCharacterEncoding("utf-8");
        //获取身份证号
        String cardId = req.getParameter("cardId");

        BookingService service = new BookingService();
        int i = service.queryBookingByCardId(cardId);

        //System.out.println(i);
        boolean flag = false;
        if (i != 0) {
            //	System.out.println(i);
            flag = true;

        } else {
            flag = false;
        }

        PrintWriter out = resp.getWriter();
        out.print(flag);
        out.flush();
        out.close();

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // TODO Auto-generated method stub
        super.doPost(req, resp);
    }
}
